package com.ssl.admin.repo;

import com.ssl.admin.pojo.CommoditySku;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface CommoditySkuRepository extends JpaRepository<CommoditySku, Long> {

    List<CommoditySku> getBySpuId(Long spuId);

    @Query(value = "update commodity_sku sku set sku.is_valid=1 where sku.id in :skuIds", nativeQuery = true)
    @Modifying
    @Transactional
    void updateSkuOnSaleStatus(List<Object> skuIds);
}